package com.yc.cloud.api.service.impl;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.yc.cloud.api.service.SysDictCacheService;
import com.yc.cloud.common.cache.service.RedisService;
import com.yc.cloud.entity.SysDict;
import jakarta.annotation.Resource;
import lombok.val;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysDictCacheServiceImpl implements SysDictCacheService {

    @Resource
    private RedisService<String> redisService;

    @Override
    public SysDict getByKey(String key) {
        val value = redisService.get(key);
        if (StrUtil.isNotEmpty(value)) {
            return JSONUtil.toBean(value, SysDict.class);
        }
        return null;
    }

    @Override
    public void setByKey(String key, SysDict sysDict) {
        redisService.set(key, JSONUtil.toJsonStr(sysDict));
    }

    @Override
    public void setByKey(String key, SysDict sysDict, long expire) {

    }

    @Override
    public boolean existByKey(String key) {
        return redisService.hasKey(key);
    }

    @Override
    public List<SysDict> listByKey(String key, long pageNum, long pageSize) {
        return null;
    }

    @Override
    public void delByKey(String key) {
        redisService.del(key);
    }

    @Override
    public List<SysDict> listAllByKey(String key) {
        //return redisService.lRange(key, 0, -1);
        return null;
    }

    @Override
    public void lPushAllByCollectionByKey(String key, List<SysDict> list) {
        redisService.lPushAllByCollection(key, list, expire);
    }

    @Override
    public SysDict get(Long id) {
        return null;
    }

    @Override
    public void set(Long id, SysDict sysDict) {

    }

    @Override
    public boolean exist(Long id) {
        return false;
    }

    @Override
    public List<SysDict> list(long pageNum, long pageSize) {
        return null;
    }

    @Override
    public List<SysDict> listAll() {
        return null;
    }

    @Override
    public void del(Long id) {

    }
}
